package com.example.exercise.initializer;

import org.jasypt.encryption.StringEncryptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * 输出加密后的参数放到配置文件
 */
@Component
public class MyEncryptRunner implements CommandLineRunner {
    @Autowired
    private StringEncryptor stringEncryptor;
    @Value("${spring.datasource.username}")
    private String username;
    @Value("${spring.datasource.password}")
    private String password;

    @Override
    public void run(String... args) {
        System.out.println("username : " + stringEncryptor.encrypt("root"));
        System.out.println("username : " + stringEncryptor.encrypt("root"));
        System.out.println("password : " + stringEncryptor.encrypt("123456"));
        System.out.println("password : " + stringEncryptor.encrypt("123456"));
        System.out.println(username);
        System.out.println(password);
    }
}
